package com.test;

import java.text.SimpleDateFormat;
import java.util.Calendar;

import antlr.collections.List;

import com.taobao.api.ApiException;
import com.taobao.api.DefaultTaobaoClient;
import com.taobao.api.TaobaoClient;
import com.taobao.api.domain.ItemImg;
import com.taobao.api.request.ItemGetRequest;
import com.taobao.api.response.ItemGetResponse;

public class Main {

	//获取应用sessionKey地址： http://container.api.taobao.com/container?appkey=12472324
	
	protected static String url = "http://gw.api.taobao.com/router/rest";// 沙箱环境调用地址http://gw.api.tbsandbox.com/router/rest

	// 正式环境需要设置为:http://gw.api.taobao.com/router/rest
	protected static String appkey = "12472324";

	protected static String appSecret = "10db926d56cf7c6aa52b6ecd00368d19";

	public static String getTime(int day) {
		// Format f = new SimpleDateFormat("yyyy-MM-dd");
		Calendar c = Calendar.getInstance();
		c.add(Calendar.DATE, day);
		return new SimpleDateFormat("yyyyMMdd").format(c.getTime());
	}

	public static void testUserGet() {
		TaobaoClient client = new DefaultTaobaoClient(url, appkey, appSecret);// 实例化TopClient类
		for (int i = 0; i < 1; i++) {
			ItemGetRequest req = new ItemGetRequest();
			//detail_url,num_iid,title,nick,type,cid,seller_cids,props,input_pids,input_str,desc,pic_url,num,valid_thru,list_time,delist_time,stuff_status,location,price,post_fee,express_fee,ems_fee,has_discount,freight_payer,has_invoice,has_warranty,has_showcase,modified,increment,approve_status,postage_id,product_id,auction_point,property_alias,item_img,prop_img,sku,video,outer_id,is_virtual
			req
			        .setFields(" detail_url,title,desc,pic_url,price,item_img");
			req.setNumIid(13585586278l);
			try {
				ItemGetResponse response = client.execute(req, "");
				for(ItemImg img:response.getItem().getItemImgs()){
					
					System.err.println("url==="+img.getUrl());
					
				}
				System.err.println(response.getItem().getDetailUrl());
				//System.err.println(response.getItem().getDesc());
				System.err.println(response.getItem().getPrice());
				System.err.println(response.getItem().getTitle());
				System.err.println("ems===="+response.getItem().getEmsFee());
			}
			catch (ApiException e) {
				e.printStackTrace();
			}

		}

	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		testUserGet();
	}
}
